home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / relay / hdrcommon.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  2KB  |  73 lines

  1. /*
  2.  * Usenet header common code.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include "libc.h"
  8. #include "news.h"
  9. #include "headers.h"
  10. #include "hdrint.h"
  11.  
  12. void
  13. hdrdebug(state)
  14. int state;
  15. {
  16.     headdebug = state;
  17. }
  18.  
  19. void
  20. hdrinit(hdrs)            /* zero all elements of hdrs */
  21. register struct headers *hdrs;
  22. {
  23.     hdrs->h_subj = NULL;
  24.     hdrs->h_ngs = NULL;
  25.     hdrs->h_distr = NULL;
  26.     hdrs->h_ctlcmd = NULL;
  27.     hdrs->h_approved = NULL;
  28.     hdrs->h_msgid = NULL;
  29.     hdrs->h_artid = NULL;
  30.     hdrs->h_expiry = NULL;
  31.     hdrs->h_path = NULL;
  32.     hdrs->h_sender = NULL;
  33. }
  34.  
  35. boolean
  36. oldctl(hdrs)            /* true iff ngs are OLDCNTRL (cache in hdrs) */
  37. register struct headers *hdrs;
  38. {
  39. #ifdef SLOWCTLMATCH
  40.     return ngmatch(OLDCNTRL, hdrs->h_ngs);
  41. #else
  42.     register int ngslen = strlen(hdrs->h_ngs);
  43.  
  44.     if (ngslen < STRLEN(SFXOLDCNTRL))    /* ngs too short */
  45.         return NO;
  46.     else                    /* check for .ctl suffix */
  47.         /*
  48.          * This is more general than RFC 850 specifies, but this
  49.          * generality seems harmless.  This doesn't work for e.g.
  50.          * x.y.ctl,z.q, which is a darn shame, but that's a violation
  51.          * of common sense.
  52.          */
  53.         return STREQ(&hdrs->h_ngs[ngslen-STRLEN(SFXOLDCNTRL)],
  54.             SFXOLDCNTRL);
  55. #endif                        /* SLOWCTLMATCH */
  56. }
  57.  
  58. void
  59. freeheaders(hdrs)        /* free (assumed) malloced storage */
  60. register struct headers *hdrs;
  61. {
  62.     nnfree(&hdrs->h_subj);
  63.     nnfree(&hdrs->h_ngs);
  64.     nnfree(&hdrs->h_distr);
  65.     nnfree(&hdrs->h_ctlcmd);
  66.     nnfree(&hdrs->h_approved);
  67.     nnfree(&hdrs->h_msgid);
  68.     nnfree(&hdrs->h_artid);
  69.     nnfree(&hdrs->h_expiry);
  70.     nnfree(&hdrs->h_path);
  71.     nnfree(&hdrs->h_sender);
  72. }
  73.